import tkinter as tk
import os,sys
TEST_NAME=sys.argv[1]
# def on_test_click():
#     root.destroy()  # 退出程序
def on_test_click():
    # 清除按钮
    test_label.pack_forget()
    test_button.pack_forget()
    
    # 显示“测试完成”标签
    completion_label = tk.Label(root, text="测试已完成", font=("Times", 20), fg="red")
    completion_label.pack(pady=20)
    
    # 可选：添加一个“关闭”按钮
    close_button = tk.Button(root, text="关闭", command=root.destroy, width=10)
    close_button.pack(pady=10)


# 创建主窗口
root = tk.Tk()
root.title(TEST_NAME+'测试')

# 设置窗口大小（可根据需要调整）
root.geometry("600x400")
root.resizable(False, False)  # 禁止调整窗口大小

# 居中窗口
def center_window(win):
    win.update_idletasks()
    width = win.winfo_width()
    height = win.winfo_height()
    x = (win.winfo_screenwidth() // 2) - (width // 2)
    y = (win.winfo_screenheight() // 2) - (height // 2)
    win.geometry(f'{width}x{height}+{x}+{y}')

center_window(root)

# 创建并放置按钮
test_label = tk.Label(root, text=f"点击进行{TEST_NAME}测试",font=("Times", 20), fg="red", cursor="hand2")
test_label.pack(expand=True)
test_button = tk.Button(root, text="start", command=on_test_click, width=20, height=2)
test_button.pack(expand=True)

# 运行主循环
root.mainloop()
